Unit BDojoxGridContainerLiteUnit;

{$mode objfpc}{$H+}

Interface

Uses
  Classes, SysUtils, BDojoSessionUnit, BDijitWidgetUnit, BDijitLayoutWidgetUnit;

Type

{ BDojoxGridContainerLiteClass }

 BDojoxGridContainerLiteClass = Class(BDijitLayoutWidgetClass)
  Private
    bAcceptTypes: String;
    bAutoRefresh: Boolean;
    bColWidth: String;
    bDoLayout: Boolean;
    bDragHandleClass: String;
    bIsAutoOrganized: Boolean;
    bNBZones: Integer;
    Procedure SetAcceptTypes(aValue: String);
    Procedure SetAutoRefresh(aValue: Boolean);
    Procedure SetColWidth(aValue: String);
    Procedure SetDoLayout(aValue: Boolean);
    Procedure SetDragHandleClass(aValue: String);
    Procedure SetIsAutoOrganized(aValue: Boolean);
    Procedure SetNBZones(aValue: Integer);
  Public
    //** The GridContainer will only accept the children that fit to the types.
    Property AcceptTypes: String Read bAcceptTypes Write SetAcceptTypes;
    //** Enable the refresh of registered areas on drag start.
    Property AutoRefresh: Boolean Read bAutoRefresh Write SetAutoRefresh;
    //** A comma separated list of column widths. If the column widths do not
    //** add up to 100, the remaining columns split the rest of the width
    //** evenly between them.
    Property ColWidth: String Read bColWidth Write SetColWidth;
    //** If true, change the size of my currently displayed child to match my
    //** size.
    Property DoLayout: Boolean Read bDoLayout Write SetDoLayout;
    //** CSS class enabling a drag handle on a child.
    Property DragHandleClass: String Read bDragHandleClass
      Write SetDragHandleClass;
    //** If true, widgets are organized automatically, else the attribute colum
    //** of child will define the right column.
    Property IsAutoOrganized: Boolean Read bIsAutoOrganized
      Write SetIsAutoOrganized;
    //** The number of dropped zones, by default 1.
    Property NBZones: Integer Read bNBZones Write SetNBZones;

    //** Inserts specified child widget's dom node as a child of this widget's
    //** container node, and possibly does other processing (such as layout).
    //** !!! Associated when add !!!
    Procedure AddChild(Const aWidget: BDijitWidgetClass);
    //** Inserts specified child widget's dom node as a child of this widget's
    //** container node, and possibly does other processing (such as layout).
    Procedure AddChild(Const aWidget: BDijitWidgetClass;
      Const aColumn: Integer);

    //** Disable the Drag And Drop for children of GridContainer.
    Procedure DisableDnD;
    //** Enable the Drag And Drop for children of GridContainer.
    Procedure EnableDnD;

    Constructor Build(Const aSession: BDojoSessionClass;
      Const aJSType: String = ''); override;
End;

Implementation

{ BDojoxGridContainerLiteClass }

Procedure BDojoxGridContainerLiteClass.SetAcceptTypes(aValue: String);
Begin
  bAcceptTypes := aValue;
  SetConfig('acceptTypes', aValue, FALSE);
End;

Procedure BDojoxGridContainerLiteClass.SetAutoRefresh(aValue: Boolean);
Begin
  bAutoRefresh := aValue;
  SetConfig('autoRefresh', aValue);
End;

Procedure BDojoxGridContainerLiteClass.SetColWidth(aValue: String);
Begin
  bColWidth := aValue;
  SetConfig('colWidth', aValue);
End;

Procedure BDojoxGridContainerLiteClass.SetDoLayout(aValue: Boolean);
Begin
  bDoLayout := aValue;
  SetConfig('doLayout', aValue);
End;

Procedure BDojoxGridContainerLiteClass.SetDragHandleClass(aValue: String);
Begin
  bDragHandleClass := aValue;
  SetConfig('dragHandleClass', aValue);
End;

Procedure BDojoxGridContainerLiteClass.SetIsAutoOrganized(aValue: Boolean);
Begin
  bIsAutoOrganized := aValue;
  SetConfig('isAutoOrganized', aValue);
End;

Procedure BDojoxGridContainerLiteClass.SetNBZones(aValue: Integer);
Begin
  bNBZones := aValue;
  SetConfig('nbZones', aValue);
End;

Procedure BDojoxGridContainerLiteClass.AddChild(
  Const aWidget: BDijitWidgetClass);
Begin
  Inherited
End;

Procedure BDojoxGridContainerLiteClass.AddChild(
  Const aWidget: BDijitWidgetClass; Const aColumn: Integer);
Begin
  If aColumn = -1 Then AddChild(aWidget)
  Else AddAjax('addChild(%s, %d);', [aWidget.JSName, aColumn]);
End;

Procedure BDojoxGridContainerLiteClass.DisableDnD;
Begin
  AddAjax('disableDnd();');
End;

Procedure BDojoxGridContainerLiteClass.EnableDnD;
Begin
  AddAjax('enableDnd();');
End;

Constructor BDojoxGridContainerLiteClass.Build(
  Const aSession: BDojoSessionClass; Const aJSType: String);
Begin
  If aJSType = '' Then
    Inherited Build(aSession, 'dojox.layout.GridContainerLite')
  Else
    Inherited Build(aSession, aJSType)
End;

End.
